﻿using System;
using Combat;
using Locomotion;
using UnityEngine;
using World;

namespace Controls
{
    public class HitterAi : MonoBehaviour
    {
        private Health _health;
        private Mover _mover;


        private void Awake()
        {
            _health = GetComponent<Health>();
            _mover = GetComponent<Mover>();
            
            _health.Died += Health_Died;
        }

        private void Update()
        {
            Vector2 moveDirection = (WorldInfo.Instance.Player.position - transform.position).normalized;
            _mover.Move(moveDirection);
        }
        
        private void Health_Died()
        {
            enabled = false;
        }
    }
}